package org.jsets.fastboot.oss.config;

import org.jsets.fastboot.util.SpringContextHolder;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.context.EnvironmentAware;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;
import lombok.extern.slf4j.Slf4j;

/**
 * 系统配置
 *
 * @author wangjie (https://github.com/wj596)
 * @date 2021.07.12 21:49
 */
@Slf4j
@Configuration
@EnableConfigurationProperties({ ObjectStorageProperties.class })
public class ObjectStorageAutoConfig implements ApplicationContextAware,EnvironmentAware{

	@Autowired
	private ObjectStorageProperties properties;
	
	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		SpringContextHolder.setApplicationContextIfNecessary(applicationContext);
	}

	@Override
	public void setEnvironment(Environment environment) {
		SpringContextHolder.setEnvironmentIfNecessary(environment);
	}

}